package com.kanesoft.android.gdx.actors.fight;

import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputAdapter;

public class ControlActorFightKeyboard extends InputAdapter   {

    private FightActorObject controlledActor;
    
    public ControlActorFightKeyboard(FightActorObject controlledActor) {
        this.controlledActor = controlledActor;
    }

    @Override
    public boolean keyDown(int keycode) {
        if (keycode == Keys.A) {
            if (controlledActor.getHorizontalFlip() == true) {
                controlledActor.doActionWalkingForward();    
            } else {
                controlledActor.doActionWalkingBackward();
            }
        }
        
        if (keycode == Keys.D) {
            if (controlledActor.getHorizontalFlip() == false) {
                controlledActor.doActionWalkingForward();    
            } else {
                controlledActor.doActionWalkingBackward();
            }
        }
        
        if (keycode == Keys.S) controlledActor.doActionKick();
        if (keycode == Keys.W) controlledActor.doActionJump();
        if (keycode == Keys.X) controlledActor.doActionPunch();
        if (keycode == Keys.F) controlledActor.doActionThrowFireball();

        return false;
    }

    @Override
    public boolean keyUp(int keycode) {
        if (keycode == Keys.D) controlledActor.doActionWaiting();
        if (keycode == Keys.A) controlledActor.doActionWaiting();
        return false;
    }

}
